<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Edit event</title>
    </h:head>
    <h:body>
        <div align="center">
            <h:form>
                <h:panelGrid columns="2" cellpadding="5">

                    <p:outputLabel for="description" value="Description:"/>
                    <p:inputText id="description" value="#{eventsBean.description}" required="true" />

                    <p:outputLabel for="startDate" value="Starting date:" />
                    <p:calendar id="startDate" value="#{eventsBean.startDate}" pattern="MM/dd/yyyy HH:mm:ss" required="true" />

                    <p:outputLabel for="endDate" value="Ending date:" />
                    <p:calendar id="endDate" value="#{eventsBean.endDate}" pattern="MM/dd/yyyy HH:mm:ss" required="true" />

                    <p:outputLabel for="place" value="Place:"/>
                    <p:inputText id="place" value="#{eventsBean.place}" required="true" />

                    <h:outputText value="Outdoor: " />
                    <p:selectBooleanCheckbox value="#{eventsBean.inOut}" />

                    <h:outputText value="Privacy: " />
                    <p:selectBooleanCheckbox value="#{eventsBean.privacy}" />

                    <h:panelGrid columns="3" cellpadding="5">
                        <h:outputLabel for="menu" value="Invite:" />
                        <p:selectCheckboxMenu id="menu" value="#{eventsBean.selectedUsers}" label="Users"
                                              filter="true" filterMatchMode="startsWith" panelStyle="width:250px">
                            <f:selectItems value="#{eventsBean.users}" />
                        </p:selectCheckboxMenu>
                        <p:commandLink value="Submit" update="display" />
                    </h:panelGrid>

                    <p:outputPanel id="display" style="width:250px;padding-left:5px;margin-top:10px">
                        <p:dataList value="#{eventsBean.selectedUsers}" var="user" emptyMessage="No users selected">
                            #{user}
                        </p:dataList>
                    </p:outputPanel>

                    <p:commandButton action="#{eventsBean.submit}" value="Save" ajax="true" update="@all"/>
                    <h:button value="Cancel" outcome="/user/home" />
                </h:panelGrid>

                <h:messages  style="color: red"/>
            </h:form>
        </div>
    </h:body>
</html>
